package com.xk.supply.web;


import com.xk.supply.pojo.po.DispatchTask;
import com.xk.supply.service.DispatchTaskService;
import com.xk.supply.utils.CommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
 */
@Controller
@RequestMapping("/basic")
@Slf4j
public class BasicController {
    @Resource
    private DispatchTaskService dispatchTaskService;

    // http://127.0.0.1:8080/hello?name=lisi
    @RequestMapping("/hello")
    @ResponseBody
    public String hello(HttpServletRequest request, @RequestParam(name = "name", defaultValue = "unknown user") String name) {
        MDC.put("traceId","123456789");
        String ipAddr = CommonUtils.getIpAddr(request);
        DispatchTask dispatchTask = dispatchTaskService.getDispatchTaskMapper(90610L);
        System.out.println(dispatchTask);
        try {
            CommonUtils.validateParam(dispatchTask,"orgCode");
        }catch (Exception e){
            log.error(e.getMessage());
        }
        System.out.println("我草"+name);
        log.info("欢迎欢迎 。。。。。。{}",name);
        return "Hello " + name;
    }



}
